package controle.gui.principal;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import org.jdesktop.swingx.JXImagePanel;
import java.awt.Toolkit;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class Login extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private JTextField tfUsuario;
	private JPasswordField passwordField;
	JLabel jlMensagem ;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			Login dialog = new Login();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public Login() {
		setIconImage(Toolkit.getDefaultToolkit().getImage("/home/jorge/Imagens/Log.jpg"));
		setBounds(100, 100, 250, 250);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		JXImagePanel imagePanel = new JXImagePanel();
		imagePanel.setImage(Toolkit.getDefaultToolkit().getImage("/home/jorge/Imagens/images.jpg"));
		imagePanel.setBounds(0, 0, 246, 224);
		contentPanel.add(imagePanel);
		imagePanel.setLayout(null);
		
		JLabel lblUsuario = new JLabel("USUARIO");
		lblUsuario.setFont(new Font("Dialog", Font.BOLD, 13));
		lblUsuario.setBounds(85, 12, 70, 14);
		imagePanel.add(lblUsuario);
		
		tfUsuario = new JTextField();
		tfUsuario.setFont(new Font("Dialog", Font.PLAIN, 13));
		tfUsuario.setBounds(12, 38, 222, 23);
		imagePanel.add(tfUsuario);
		tfUsuario.setColumns(10);
		
		JLabel lblSenha = new JLabel("SENHA");
		lblSenha.setFont(new Font("Dialog", Font.BOLD, 13));
		lblSenha.setBounds(85, 80, 70, 14);
		imagePanel.add(lblSenha);
		
		passwordField = new JPasswordField();
		passwordField.setBounds(12, 116, 222, 23);
		imagePanel.add(passwordField);
		
		JButton btnCancelar = new JButton("Sair");
		btnCancelar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			System.exit(0);
			}
		});
		btnCancelar.setHorizontalAlignment(SwingConstants.LEADING);
		btnCancelar.setIcon(new ImageIcon("/home/jorge/Imagens/Sairjp.jpg"));
		btnCancelar.setBounds(130, 167, 106, 24);
		imagePanel.add(btnCancelar);
		
		JButton btnNewButton = new JButton("Logar");
		btnNewButton.setIcon(new ImageIcon("/home/jorge/Imagens/Chaves.jpg"));
		btnNewButton.setHorizontalAlignment(SwingConstants.LEADING);
		
		btnNewButton.setBounds(9, 167, 109, 24);
		imagePanel.add(btnNewButton);
		
		jlMensagem = new JLabel("");
		jlMensagem.setBounds(42, 203, 181, 14);
		imagePanel.add(jlMensagem);
		preencheCampos();
	}
	public void preencheCampos()
	{
		//this.tfUsuario.setForeground(Color.CYAN);  
		//this.tfUsuario.setText("Campo preenchimento origatorio");
		
	}
	public void login()
	{
		this.jlMensagem.setText("Usuario ou senha incorretos");
	}
}
